package com.dqs.comment.result;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.TreeMap;

public class Result<T> {
    private Integer code;

    private String massage;

    private T data;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMassage() {
        return massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    private Result(ResultEnum re) {
        this.code = re.getCode();
        this.massage = re.getMessage();
    }

    private Result(ResultEnum re, T data) {
        this.code = re.getCode();
        this.massage = re.getMessage();
        this.data = data;
    }

    public static Result<?> error(ResultEnum re){

        return new Result<>(re);
    }
    public static <T> Result<?> error(ResultEnum re, T data){

        return new Result<>(re, data);
    }
    public static Result<?> success(){

        return new Result<>(ResultEnum.SUCCESS);
    }
    public static <T> Result<?> success(T data){

        return new Result<>(ResultEnum.SUCCESS, data);
    }


    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", massage='" + massage + '\'' +
                ", data=" + data +
                '}';
    }
}
